<template>
  <div>
    <c-table-box ref="cTableBox" index hide-func :setting="false" :data="data" no-request :table-config="tableConfig">
      <el-table-column slot="before" type="expand" width="50">
        <template v-slot="{row}">
          <div style="padding:10px">
            <c-table-box :index="false" :data="filterData(row.shopAttachmentDTOList)" hide-func :setting="false" :table-config="tableConfigAtt" />
          </div>
        </template>
      </el-table-column>
    </c-table-box>
    <ApproveLog :id="row.id" ref="appLog" />
  </div>
</template>
<script>
import ApproveLog from './ApproveLog'
export default {
  name: 'PicAtt',
  components: {
    ApproveLog
  },
  props: {
    data: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      visible: false,
      row: {},
      isDetail: 0,
      tableConfig: {
        setting: [
          {
            prop: '',
            label: '操作',
            minWidth: 140,
            render: (h, row) => {
              return h('el-button', {
                props: {
                  type: 'text'
                },
                on: {
                  click: () => {
                    this.row = row
                    this.$refs.appLog.openDialog()
                  }
                }
              }, '查看审批记录')
            }
          },
          {
            prop: 'picBatchCode',
            label: '图纸批号',
            minWidth: 120
          },
          // {
          //   prop: 'pictureName',
          //   label: '图纸名称'
          // },
          {
            prop: 'pictureNature',
            label: '图纸性质',
            minWidth: 120,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'PICTURE_NATURE'
            }
          },
          {
            prop: 'isNeedAdjustOutpicDetail',
            label: '是否需要修改出图明细',
            minWidth: 160,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'isNeedApproval',
            label: '是否需要审批',
            minWidth: 140,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'isValid',
            label: '是否有效',
            minWidth: 120,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'customerConfirmResult',
            label: '经销商确认结果',
            minWidth: 120,
            render: (h, row) => {
              return h('span', this.resultHandle(row.customerConfirmResult))
            }
            // propEnum: {
            //   domainCode: 'marketing',
            //   appCode: 'slm',
            //   dictTypeCode: 'BOOLEANS'
            // }
          },
          {
            prop: 'customerFeedbackAdvice',
            label: '经销商反馈意见',
            minWidth: 140
          },
          {
            prop: 'managerReviewResult',
            label: '客户经理审核结果',
            minWidth: 140,
            // render: (h, row) => {
            //   return h('span', this.resultHandle(row.managerReviewResult))
            // },
            formatData: row => {
              const v = row.managerReviewResult
              if (v === 1 || v === '1') {
                return '同意商家确认结果'
              } else if (v === 0 || v === '0') {
                return '不同意商家确认结果'
              }
              return ''
            }
            // propEnum: {
            //   domainCode: 'marketing',
            //   appCode: 'slm',
            //   dictTypeCode: 'BOOLEANS'
            // }
          },
          {
            prop: 'managerReviewAdvice',
            label: '客户经理审核意见',
            minWidth: 140
          }
        ]
      },
      tableConfigAtt: {
        setting: [
          {
            prop: '',
            label: '操作',
            className: 'btn-green',
            width: 120,
            render: (h, row) => {
              return h('el-button', {
                props: {
                  type: 'text'
                },
                on: {
                  click: () => {
                    this.fileDown(row)
                  }
                }
              }, '下载')
            }
          },
          {
            prop: '',
            label: '图纸预览',
            width: 120,
            render: (h, row) => {
              return h('c-accessory', {
                props: {
                  src: row.attachmentUrl,
                  type: row.typeName,
                  width: '100px',
                  height: '60px'
                }
              })
            }
          },
          {
            prop: 'attachmentName',
            label: '图纸名称',
            minWidth: 200
          },
          {
            prop: 'typeName',
            label: '附件类型',
            width: 120
          }
        ]
      }
    }
  },
  watch: {
  },
  created() {
    this.isDetail = this.$route.query.isDetail
  },
  methods: {
    filterData(data) {
      if (!this.isDetail) {
        return data
      } else {
        const files = data.filter(v => v.typeName !== 'dwg')
        return files
      }
    },
    fileDown(row) {
      this.$downFile(row)
    },
    resultHandle(v) {
      return v === undefined || v === '' || v === null ? '' : v.toString() === '1' ? '同意' : '不同意'
    }
  }
}
</script>
<style lang="scss" scoped>
.image{
  width: 48px;
  height: 48px;
}
</style>
